package com.szt.school.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class RabbitMQConfig {
    @Bean
    public Queue simpleQueue(){
        return new Queue("my_simple_queue");
    }
    @Bean
    public Queue workQueue() {
        Queue queue = new Queue("my_work_queue");
        return queue;
    }

    @Bean
    public Queue topicQueue1() {
        return new Queue("my_topic_queue1");
    }
    @Bean
    public Queue topicQueue2() {
        return new Queue("my_topic_queue2");
    }
    @Bean
    public TopicExchange exchange() {
        return new TopicExchange("my_topic_exchange");
    }
    @Bean
    public Binding bindingExchangeTopicQueue1(Queue topicQueue1, TopicExchange exchange) {
        return BindingBuilder.bind(topicQueue1).to(exchange).with("topic. *.msg1");
    }
    @Bean
    public Binding bindingExchangeTopicQueue2(Queue topicQueue2, TopicExchange exchange) {
        return BindingBuilder.bind(topicQueue2).to(exchange).with("topic.#");
    }
}
